package com.netintech.intelligenceInterface.iflytek.controller;

import com.netintech.intelligenceInterface.common.StaticBean;
import com.netintech.intelligenceInterface.iflytek.domain.textSimilarityTest.TextSimilarityTestParam;
import com.netintech.intelligenceInterface.iflytek.util.HeadersUtil;
import com.netintech.intelligenceInterface.iflytek.util.RestTemplateUtil;
import org.apache.tomcat.util.http.HeaderUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import static com.netintech.intelligenceInterface.iflytek.domain.IFlyTekKey.API_KEY;
import static com.netintech.intelligenceInterface.iflytek.domain.IFlyTekKey.API_SECRET;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @author lining
 * @date 2021/4/27 15:17
 * 文本相似度检测接口
 */
@RestController
public class TextSimilarityTestController {
    /**
     * 单文本相似度检测路径
     */
    private static final String SINGLE_TEXT_SIMILARITY_CHECK_URL = "/tuling/tsc/v2/singleprocess";
    /**
     * 多文本相似度检测路径
     */
    private static final String MULTI_TEXT_SIMILARITY_CHECK_URL = "/tuling/tsc/v2/multiprocess";

    @PostMapping("/singleTextSimilarityCheck")
    public String singleTextSimilarityCheck(@RequestBody TextSimilarityTestParam param) {
        String url = StaticBean.URL1 + SINGLE_TEXT_SIMILARITY_CHECK_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("/multiTextSimilarityCheck")
    public String multiTextSimilarityTest(@RequestBody List<TextSimilarityTestParam> param) {
        String url = StaticBean.URL1 + MULTI_TEXT_SIMILARITY_CHECK_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("/test/singleTextSimilarityCheck")
    public String singleTextSimilarityCheckTest(@RequestBody TextSimilarityTestParam param) {
        String url = StaticBean.URL1 + SINGLE_TEXT_SIMILARITY_CHECK_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("/test/multiTextSimilarityCheck")
    public String multiTextSimilarityCheckTest(@RequestBody List<TextSimilarityTestParam> param) {
        String url = StaticBean.URL1 + MULTI_TEXT_SIMILARITY_CHECK_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

}
